<!-- templates/layui/admin/suggestions.html -->
{% extends "layui/admin/base.html" %}
{% block title %}导航网站 - 建议管理{% endblock %}
{% block content %}
    <blockquote class="layui-elem-quote">
        <p><a href="/admin/v2"><i class="layui-icon layui-icon-home"></i> 首页</a>
            <i class="layui-icon layui-icon-next"></i> 网站建议管理</p>
    </blockquote>
    <div class="layui-panel">
        <br>
        <div class="layui-card">
            <div class="layui-card-header">
                <h1>网站建议管理</h1>
            </div>
            <div class="layui-card-body">
                <table id="sugTable" lay-filter="sugTableFilter"></table>
            </div>
            <!-- 菜单栏 -->

        </div>
    </div>
{% endblock %}
{% block scripts %}
    <script>
        layui.use(['table', 'form', 'layer'], function () {
            const table = layui.table;
            const layer = layui.layer;
            const $ = layui.$;
            table.render({
                elem: '#sugTable',
                url: '/api/suggestions/',
                method: 'get',
                headers: {
                    'Authorization': 'Bearer ' + localStorage.getItem('token')
                },
                toolbar: '#toolbar',
                defaultToolbar: ['filter', 'print', 'exports'],

                page: true,
                parseData: function (res) {
                    return {
                        code: res.code,
                        msg: res.msg,
                        count: res.count,
                        data: res.data
                    }
                },
                cols: [[
                    {field: 'id', title: 'ID', width: 60, sort: true},
                    {field: 'site_name', title: '推荐网站', width: 200},
                    {field: 'site_url', title: '网址', width: 200},
                    {field: 'site_description', title: '推荐语', width: 200},
                    {field: 'email', title: '邮箱', width: 200},
                    {field: 'ip', title: 'IP 地址', width: 150},
                    {field: 'created_at', title: '时间', width: 200},
                    {
                        field: 'handled',
                        title: '状态',
                        width: 120,
                        templet: d => d.handled
                            ? '<span class="layui-badge layui-bg-green">已处理</span>'
                            : '<span class="layui-badge layui-bg-red">未处理</span>'

                    }
                ]]
            })
        })
    </script>
{% endblock %}